home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / FITPLOT.LI2 < prev    next >
Text File  |  1994-07-20  |  690b  |  25 lines

  1. #  library fitplot.li
  2. #  fitplot() 
  3. #  fits and plots data ( [x1,x2,...], [y1,y2,...] ) with a linear line
  4. #  e.g.    fitplot([1,2,3,4], [1,2.2,2.8,4])
  5.  
  6. fitplot(x_, y_) := block(numeric:=on,
  7.     graph,
  8.     xmax:=max(x)*1.05,
  9.     xmin:=min(x)*0.9,
  10.     ymax:=max(y)*1.05,
  11.     ymin:=min(y)*0.9,
  12.     dx:=(xmax-xmin)/getmaxx,
  13.     dy:=(ymax-ymin)/getmaxy,
  14.     length:=length(y),
  15.     axis(xmin,xmax,ymin,ymax),
  16.     do( circle((member(x,j)-xmin)/dx,getmaxy-(member(y,j)-ymin)/dy,2),
  17.     j,1,length,1),
  18.     setcolor(colorno(yellow)),
  19.     line((member(x,1)-xmin)/dx,getmaxy-(member(y,1)-ymin)/dy,
  20.     (member(x,length)-xmin)/dx,getmaxy-(member(y,length)-ymin)/dy),
  21.     numeric:=off,
  22.     readchar,
  23.     text,
  24.     local(dx,dy,length))
  25.